package com.biz.primus.model.coupon.vo.coupon.request;

import com.biz.primus.base.exception.utils.AssertUtils;
import com.biz.primus.model.coupon.exceptions.CouponExceptionType;
import com.biz.primus.model.coupon.interfaces.IModelValidation;
import com.biz.primus.model.coupon.vo.coupon.GetOrderProductAvailableCouponProductItemVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.collections4.CollectionUtils;

/**
 * 获取订单商品可用优惠券Vo
 *
 * @author david-liu
 */
@ApiModel(value = "获取订单商品可用优惠券请求Vo")
@Getter
@Setter
public class GetOrderProductAvailableCouponReqVo implements Serializable, IModelValidation {
    private static final long serialVersionUID = 5808896525849728194L;

    @ApiModelProperty(value = "用户ID")
    private Long userId;

    @ApiModelProperty(value = "获取订单商品可用优惠券商品项")
    private List<GetOrderProductAvailableCouponProductItemVo> items;

    @Override
    public void validate() {
        AssertUtils.notNull(userId, CouponExceptionType.COUPON_USER_NOT_ALLOW_NULL);
        if (CollectionUtils.isNotEmpty(items)) {
            items.forEach(GetOrderProductAvailableCouponProductItemVo::validate);
        }
    }
}
